/*
 * FacadeProdotto
 * 
 * This class implements IFacadeProdotto
 * 
 * Author: Carmine Colicino, Luigi Di Martino
 * Version: 1.0
 * 
 * 2014 - Copyright by Team 6 - University of Salerno
*/

package it.unisa.udocs.facade;

import java.util.ArrayList;

import it.unisa.udocs.data.*;
import it.unisa.udocs.storage.DBProdotto;

public class FacadeProdotti implements IFacadeProdotti {
	
	/**
	 * 
	 * Is used to search for a Validated Product Stored in our System
	 * 
	 *@param campiCompilati - An Array containing information about the product what we are searching for 
	 * 
	 *@return An Array containing All Products Found
	 * 
	 */
	public ArrayList<Prodotto> ricercaProdotti(
			ArrayList<String> campiCompilati) {
		return DBProdotto.getInstance().getProdottiRicerca(campiCompilati);
	}
	
	/**
	 * Is used to search for a Product Stored in our System
	 * 
	 * @param campiCompilati - An Array containing information of the product what we are searching for
	 * 
	 *  @return An Array containing All Products Found
	 * 
	 */
	public ArrayList<Prodotto> ricercaProdottiAdmin(
			ArrayList<String> campiCompilati) {
		return DBProdotto.getInstance().getProdottiRicercaAdmin(
				campiCompilati);
	}
	
	/**
	 * Is used to search for all Products of a specific researcher
	 * 
	 * @param id_account - The Id of the researcher's account
	 * 
	 *  @return An Array containing All researcher's products 
	 * 
	 */
	public ArrayList<Prodotto> listaProdottiPersonali(int id_account) {
		return DBProdotto.getInstance().getProdottiById(id_account);
	}
	
	/**
	 * Is used to search for a Product specifying its ID 
	 * 
	 * @param id_Prodotto - The Product's Id 
	 * 
	 *  @return Return An Array Containing the Product found 
	 * 
	 */
	public ArrayList<Prodotto> getProdottoByIdProdotto(int id_prodotto) {
		return DBProdotto.getInstance().getProdottoByIdProdotto(id_prodotto);
		
	}
	
	/**
	 * Is Used to store a Product in the System
	 * 
	 * @param prod - Product 
	 * 
	 *  @return The Product's Id 
	 * 
	 */
	public int inserisciProdotto(Prodotto prod) {
		return DBProdotto.getInstance().inserisciProdotto(prod);
	}
	
	/**
	 * Is Used To store an Article in a book in the system
	 * 
	 * @param artLib - The Article in a book 
	 * 
	 */
	public void inserisciArticoloLibro(ArticoloLibro artLib) {
		DBProdotto.getInstance().inserisciArticoloLibro(artLib);
	}
	
	/**
	 * Is used to insert a magazine article in the system
	 * 
	 * @param artRiv - The magazine article
	 * 
	 */
	public void inserisciArticoloRivista(ArticoloRivista artRiv) {
		DBProdotto.getInstance().inserisciArticoloRivista(artRiv);
	}
	
	/**
	 * Is used to store a monograph in the system
	 * 
	 * @param monograf - The monograph 
	 * 
	 */
	public void inserisciMonografia(Monografia monograf) {
		DBProdotto.getInstance().inserisciMonografia(monograf);
	}
	
	/**
	 * Is used to store a proceeding in our system
	 * 
	 * @param proceed - The proceeding 
	 * 
	 */
	public void inserisciProceeding(Proceeding proceed) {
		DBProdotto.getInstance().inserisciProceeding(proceed);
	}
	
	/**
	 * Is used to store a patent in our system
	 * 
	 * @param brev - The patent
	 * 
	 */
	public void inserisciBrevetto(Brevetto brev) {
		DBProdotto.getInstance().inserisciBrevetto(brev);
	}
	
	/**
	 * Is used to store a "Curatela"
	 * 
	 * @param curat - The Curatela
	 * 
	 */
	public void inserisciCuratela(Curatela curat) {
		DBProdotto.getInstance().inserisciCuratela(curat);
	}
	
	/**
	 * Is used to store a generic Product 
	 * 
	 * @param altro - The product 
	 * 
	 */
	public void inserisciAltroProdotto(AltroProdotto altro) {
		DBProdotto.getInstance().inserisciAltroProdotto(altro);
	}
	
	/**
	 * Is used to remove a product from our System
	 * 
	 * @param prod  - The product 
	 * 
	 */
	public void eliminaProdotto(Prodotto prod) {
		DBProdotto.getInstance().eliminaProdotto(prod);
	}
	
	/**
	 * Is used to modify a specific product 
	 * 
	 * @param prod - The product 
	 * @param oldTipologia - The old Product's Kind
	 * 
	 */
	public void modificaProdotto(Prodotto prod, String oldTipologia) {
		DBProdotto.getInstance().modificaProdotto(prod, oldTipologia);
	}
	
	/**
	 * Is used To store a notification in our System
	 * 
	 * @param notif - The notification
	 * 
	 */
	public void inserisciNotifica(Notifica notif) {
		DBProdotto.getInstance().inserisciNotifica(notif);
	}
	
	/**
	 * Is used To check if a researcher has just received the notification,
	 * to avoid duplicate notifications on the same product
	 * 
	 * @param id_prodotto - the product id
	 * @param id_account - the account id
	 * @return true if the notifications exists, false if not
	 */
	public boolean notificaAttiva(int id_prodotto, int id_account) {
		return DBProdotto.getInstance().notificaAttiva(id_prodotto, id_account);
	}
	
	/**
	 * Is used to search for all products which are waiting for a recognition 
	 * 
	 * @param id_account - The Account's Id 
	 * 
	 * @return The list of all products that are waiting a recognition 
	 * 
	 */
	public ArrayList<Prodotto> getProdottiDaRiconoscere(int id_account) {
		return DBProdotto.getInstance().getProdottiDaRiconoscere(id_account);
	}
	
	/**
	 * It's used to confirm a cooperation on a product 
	 * 
	 * @param id_account - The account's id 
	 * @param id_prodotto - The product's id 
	 * 
	 */
	public void confermaRiconoscimento(int id_account, int id_prodotto) {
		DBProdotto.getInstance().confermaRiconoscimento(
				id_account, id_prodotto);
	}
	
	/**
	 * This method is used to reports the notifications
	 * 
	 * @param id_account - The account's id
	 * 
	 *  @return The notification's id 
	 * 
	 */
	public int segnalaNotifica(int id_account) {
		return DBProdotto.getInstance().segnalaNotifica(id_account);
	}
	
	/**
	 * It's used to verify if an User is inserting a product already inserted in the system
	 * 
	 * @param prod - The Product
	 * 
	 *  @return 0 if the product doesn't exist yet, 1 if the product already exists 
	 * 
	 */
	public int findDuplicate(Prodotto prod) {
		return DBProdotto.getInstance().findDuplicate(prod);
	}

}
